﻿import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/** note: submenu only apppear when children.length>=1
*   detail see  https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
**/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
**/
export const constantRouterMap = [
  { path: '/login', component: _import('login/index'), hidden: true },
  { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
  { path: '/404', component: _import('errorPage/404'), hidden: true },
  { path: '/401', component: _import('errorPage/401'), hidden: true },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [{
      path: 'dashboard',
      component: _import('dashboard/index'),
      name: 'dashboard',
      meta: { title: '首页', icon: 'home', noCache: true }
    }]
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/agents',
    component: Layout,
    redirect: 'noredirect',
    name: 'agents',
    meta: {
      title: '代理商管理',
      icon: 'dailishang',
      roles: [0, 1, 2]
    },
    children: [
      { path: 'my-agents', component: _import('agents/my-agents'), name: 'my-agents', meta: { title: '我的代理商', roles: [0, 1, 2] }},
      { path: 'next-agents', component: _import('agents/next-agents'), name: 'next-agents', meta: { title: '下级代理商', roles: [0, 1] }},
      { path: 'valid-agent', component: _import('agents/valid-agent'), name: 'valid-agent', meta: { title: '代理商审核', badge: true }},
      { path: 'add-agents', component: _import('agents/components/add-agents'), name: 'addAgents', meta: { title: '添加代理商' }, hidden: true },
      { path: 'edit-agents', component: _import('agents/components/edit-agents'), name: 'editAgents', meta: { title: '修改代理商资料' }, hidden: true },
      { path: 'agentsDetail', component: _import('agents/components/agents-list'), name: 'AgentsList', meta: { title: '代理商资料详情' }, hidden: true }
    ]
  },
  {
    path: '/merchant',
    component: Layout,
    redirect: 'noredirect',
    name: 'shop',
    meta: {
      title: '商户管理',
      icon: 'peoples'
    },
    children: [
      { path: 'merchantEntry', component: _import('merchant/index'), name: 'MerchantEntry', meta: { title: '我的商户' }},
      { path: 'merchantDetails', component: _import('merchant/components/merchant/merchant_details'), name: 'merchantDetails', meta: { title: '商户详情' }, hidden: true },
      { path: 'addMerchant', component: _import('merchant/components/merchant/newMerchant'), name: 'newMerchant', meta: { title: '新增商户' }, hidden: true },
      { path: 'affiliatedBusinesses', component: _import('merchant/affiliatedBusinesses'), name: 'AffiliatedBusinesses', meta: { title: '下属商户', roles: [0, 1, 2] }},
      { path: 'baseAudit', component: _import('merchant/auditBase'), name: 'auditBase', meta: { title: '基础资料审核', roles: [0] }},
      { path: 'channelAudit', component: _import('merchant/auditChannel'), name: 'auditChannel', meta: { title: '通道审核', roles: [0] }},
      { path: 'createCode', component: _import('merchant/create-code'), name: 'createCode', meta: { title: '空码预制' }},
      { path: 'validateAction', component: _import('merchant/action/validateAction'), name: 'validateAction', meta: { title: '活动审核', roles: [0] }, hidden: true },
      { path: 'wsInfo', component: _import('merchant/components/auditChannel/item/components/ws-info'), name: 'wsInfo', meta: { title: '网商商户详情' }, hidden: true },
      { path: 'reviewChannel', component: _import('merchant/components/auditChannel/review/channel'), name: 'ReviewChannel', meta: { title: '通道审核详情', roles: [0] }, hidden: true },
      { path: 'reviewBase', component: _import('merchant/components/auditChannel/review/base'), name: 'ReviewBase', meta: { title: '基础资料审核详情', roles: [0] }, hidden: true },
      { path: 'channelBase', component: _import('merchant/components/auditChannel/item/base-list'), name: 'channelBaseList', meta: { title: '基础资料详情', roles: [0] }, hidden: true },
      { path: 'affiliatedBusinessesList', component: _import('merchant/components/affiliatedBusinesses/list'), name: 'affiliatedBusinessesList', meta: { title: '下属商户详情' }, hidden: true },
      { path: 'checkShop', component: _import('merchant/components/store/check-shop'), hidden: true, meta: { title: '查看门店' }, name: 'checkShop', children: [
        { path: 'terminal', component: _import('merchant/components/store/components/index'), meta: { title: '查看终端' }, hidden: true, name: 'terminal', children: [
          { path: 'bindTerminal', component: _import('merchant/components/store/components/bindTerminal'), name: 'bindTerminal', meta: { title: '绑定终端' }, hidden: true },
          { path: 'cloudSpeaker', component: _import('merchant/components/store/components/cloudSpeaker'), name: 'cloudSpeaker', meta: { title: '云喇叭管理' }, hidden: true }
        ] }
      ] },
      { path: 'addStore', component: _import('merchant/components/store/add-store'), name: 'addStore', meta: { title: '添加门店' }, hidden: true },
      { path: 'editStore', component: _import('merchant/components/store/edit-store'), name: 'editStore', meta: { title: '修改门店' }, hidden: true },
      { path: 'checkUser', component: _import('merchant/components/user/shop-user'), name: 'shopUser', meta: { title: '查看员工' }, hidden: true },
      { path: 'addUser', component: _import('merchant/components/user/add-user'), name: 'addUser', meta: { title: '添加店员' }, hidden: true },
      { path: 'editUser', component: _import('merchant/components/user/edit-user'), name: 'editUser', meta: { title: '修改店员' }, hidden: true }
    ]
  },
  {
    path: '/saleaman',
    component: Layout,
    redirect: 'noredirect',
    name: 'saleaman',
    meta: {
      icon: 'mysaleaman',
      title: '业务员管理'
    },
    children: [
      { path: 'index', component: _import('saleaman/index'), name: 'mysaleaman', meta: { title: '我的业务员' }},
      { path: 'search', component: _import('saleaman/search'), name: 'search', meta: { title: '业绩查询' }, hidden: true },
      { path: 'rebate', component: _import('saleaman/rebate'), name: 'rebate', meta: { title: '流水及返佣' }},
      { path: 'add', component: _import('saleaman/components/add'), name: 'add', meta: { title: '添加业务员' }, hidden: true },
      { path: 'edit', component: _import('saleaman/components/edit'), name: 'edit', meta: { title: '修改业务员' }, hidden: true },
      { path: 'shop', component: _import('saleaman/components/topshop'), name: 'userShop', meta: { title: '所属商户' }, hidden: true }
    ]
  },
  {
    path: '/finance',
    component: Layout,
    redirect: 'noredirect',
    name: 'finance',
    meta: {
      icon: 'rmb',
      title: '财务管理'
    },
    children: [
      { path: 'brokerage', component: _import('finance/brokerage'), name: 'brokerage', meta: { title: '佣金管理' }},
      { path: 'withdraw', component: _import('finance/withdraw'), name: 'withdraw', meta: { title: '本级提现管理', roles: [1, 2, 3] }},
      { path: 'next-withdraw', component: _import('finance/next-withdraw'), name: 'nextwithdraw', meta: { title: '下级提现管理', roles: [0, 1, 2] }},
      { path: 'order-error', component: _import('total/order-err-mes'), name: 'orderErrMes', meta: { title: '网商打款失败通知', roles: [0] }},
      { path: 'wsDownload', component: _import('finance/ws-download'), name: 'wsDownload', meta: { title: '网商对账单下载' }, hidden: true },
      // { path: 'paDownload', component: _import('finance/pa-download'), name: 'paDownload', meta: { title: '平安对账单下载', roles: [0] }},
      // { path: 'witness', component: _import('finance/witness'), name: 'witness', meta: { title: '平安见证宝', roles: [0] }},
      { path: 'broker-body', component: _import('finance/components/broker-body'), name: 'brokerBody', hidden: true, meta: { title: '佣金详情' }}
    ]
  },
  {
    path: '/total',
    component: Layout,
    redirect: 'noredirect',
    name: 'total-order',
    meta: {
      icon: 'chart',
      title: '数据统计'
    },
    children: [
      { path: 'order', component: _import('total/order'), name: 'order', meta: { title: '订单数据统计' }},
      { path: 'run', component: _import('total/run'), name: 'run', meta: { title: '官方分润数据' }, hidden: true }
    ]
  },
  {
    path: '/Terminal',
    component: Layout,
    redirect: 'noredirect',
    name: 'Terminal',
    meta: {
      title: '硬件设备管理',
      icon: 'terminal',
      roles: [0]
    },
    children: [
      { path: 'index', component: _import('terminal/TerminalAdministrate'), name: 'TerminalAdministrate', meta: { title: '终端管理' }},
      { path: 'config', component: _import('terminal/TerminalConfig'), name: 'TerminalConfig', meta: { title: '终端配置' }},
      { path: 'addConfig', component: _import('terminal/components/addConfig'), name: 'addTerminalConfig', meta: { title: '配置管理' }, hidden: true },
      { path: 'addTerminal', component: _import('terminal/components/addTerminal'), name: 'TerminalStorage', meta: { title: '终端入库' }, hidden: true }
    ]
  },
  {
    path: '/uphicoo',
    component: Layout,
    redirect: 'noredirect',
    name: 'uphicoo',
    hidden: true,
    meta: {
      icon: 'xueyuan',
      title: '嗨客学院'
    },
    children: [
      { path: 'train', component: _import('uphicoo/train'), name: 'train', meta: { title: '相关培训' }},
      { path: 'download', component: _import('uphicoo/download'), name: 'down', meta: { title: '资源下载' }, hidden: true },
      { path: 'shop', component: _import('uphicoo/shop'), name: 'uphicooShop', meta: { title: '硬件支持' }, hidden: true }
    ]
  },
  {
    path: '/setting',
    component: Layout,
    redirect: 'noredirect',
    name: 'setting',
    meta: {
      icon: 'setting',
      title: '服务商配置',
      roles: [0]
    },
    children: [
      { path: 'pay-setting', component: _import('setting/pay-setting'), name: 'payStting', meta: { title: '支付通道配置' }},
      { path: 'rates-setting', component: _import('setting/rates-setting'), name: 'ratesSetting', meta: { title: '支付费率配置' }},
      { path: 'AgentIfno', component: _import('setting/info'), name: 'infoSetting', meta: { title: '公司信息配置' }},
      { path: 'pay-advertsing', component: _import('setting/pay-advertsing'), name: 'payAdvertsing', meta: { title: '支付广告管理' }},
      { path: 'pact-setting', component: _import('setting/pact-setting'), name: 'pactSetting', meta: { title: '入驻协议管理' }},
      { path: 'wechat', component: _import('setting/wechat-config'), name: 'wechat', meta: { title: '微信公众号配置' }},
      { path: 'advertsing-list', component: _import('setting/components/advertsing-list'), name: 'AdvertsingList', meta: { title: '广告详情' }, hidden: true }
    ]
  },
  {
    path: '/system',
    component: Layout,
    redirect: 'noredirect',
    name: 'system',
    meta: {
      title: '系统设置',
      icon: 'system_logs'
    },
    children: [
      { path: 'index', component: _import('system/system-setting'), name: 'systemIndex', meta: { title: '守护进程', roles: [0] }},
      { path: 'account', component: _import('system/account'), name: 'account', meta: { title: '账号信息', roles: [1, 2, 3] }},
      { path: 'account', component: _import('system/account'), name: 'account', meta: { title: '账号信息' }, hidden: true }
    ]
  },
  {
    path: '/notice',
    component: Layout,
    redirect: 'noredirect',
    name: 'notice',
    meta: {
      title: '系统通知',
      icon: 'mesage'
    },
    children: [
      { path: 'message', component: _import('notice/message'), name: 'message', meta: { title: '我的通知', roles: [0] }},
      { path: 'get-message', component: _import('notice/get-message'), name: 'getMessage', meta: { title: '收到通知' }},
      { path: 'issue', component: _import('notice/issue'), name: 'issue', meta: { title: '发布通知', roles: [0] }, hidden: true },
      { path: 'message/list', component: _import('notice/components/list'), name: 'meslist', meta: { title: '通知详情', noCache: true }, hidden: true }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]
